<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        var entry = {
            a: {
                b: {
                    c: {
                        dd: 'abcdd'
                    }
                },
                d: {
                    xx: 'adxx'
                },
                e: 'ae'
            }
        }

        // 要求转换成如下对象
        var output = {
            'a.b.c.dd': 'abcdd',
            'a.d.xx': 'adxx',
            'a.e': 'ae'
        }
        function cc ( obj,key='',oo={}){
            for(let i in obj ) {
                if(typeof obj[i] == 'object') {
                    cc(obj[i],key+i+'.',oo)
                } else {
                    oo[key+i]=obj[i]
                    console.log(i)
                   
                }
            }
            return oo
        }
        
        console.log(cc(entry))
    //     let arr1 = []
    //     let arr2 = []
    //     function flat(obj, key = "", res = {}) {
    //         Object.keys(obj).forEach(k => {
    //             if (Object.prototype.toString.call(obj[k]) == "[object Object]") {
    //                 console.log(k)
    //                 flat(obj[k], key +k+'.', res);
    //             } else {
    //                 console.log(k)
    //                 res[key + k] = obj[k];
    //             }
    //         });
    //         return res;
    //     }
    //     console.log(flat(entry));
    //     let cc = {a:{},b:1}
    // console.log(cc['b'].toString()) 

    </script>
</body>

</html>